<template lang="">
    <div>
        <van-field v-model='form.username' label='用户名' />
        <van-field v-model='form.password' label='密码' type="password"/>
        <van-button @click='login'>登录</van-button>
    </div>
</template>

<script>
export default {
    data(){
        return{
            form:{}
        }
    },
    methods: {
        login(){
            //调用接口登录
            this.axios.post('auser/login',this.form).then(res=>{
                 //根据返回结果操作，code==200，存userid,跳转到个人中心
                 if(res.data.code ==200){
                     localStorage.setItem('userid',res.data.userid)
                     localStorage.setItem('username',res.data.username)
                     localStorage.setItem('sign',res.data.sign)
                     this.$router.push({'path':'/uinfo'})
                 }
            })
        }
    }
}
</script>

<style lang="">

</style>